const Koa=require('koa')
const app=new Koa()
const log=console.log;
const static=require('koa-static')
const path=require('path')
const render=require('koa-art-template')
const mongoose=require('mongoose')
const {connectEnv,initSchemas}=require('./model/connectdb')

;(async ()=>{  //运行app文件时自动执行
    await connectEnv()  //执行connectEnv方法完成mongoose开启debug
    initSchemas()
    require("./store/movie-cp")
})()
render(app,{
    root:__dirname,
    extname:'.html',
    debug:process.env.NODE_ENV!=='production'
})

const router=require('./routers/router')

app.use(static(path.join(__dirname,'..','public')))
app.use(router.routes())
app.listen(5001,()=>{
    log(5001)
})